package com.mccken.demo.collect.collect_01;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2024-01-12 20:55
 **/
public class MyThreadLocalMapDemo {

	public static void main(String[] args) throws InterruptedException {

		
		Thread thread1 = new Thread(() -> {
			ThreadLocal<String> t1 = new ThreadLocal<>();
			t1.set("t1");
			ThreadLocal<String> t2 = new ThreadLocal<>();
			t2.set("t2");
			try {
				Thread.sleep(10000);
			} catch (InterruptedException e) {
				throw new RuntimeException(e);
			}
			
		});
		Thread thread2 = new Thread(() -> {
			ThreadLocal<String> t = new ThreadLocal<>();
			t.set("t");
			ThreadLocal<String> t2 = new ThreadLocal<>();
			t2.set("T2");
			System.out.println(t.get());
			try {
				Thread.sleep(10000);
			} catch (InterruptedException e) {
				throw new RuntimeException(e);
			}
			
		});
		thread1.start();
		thread2.start();
		Thread thread3 = Thread.currentThread();
		ThreadLocal<Integer> t = new ThreadLocal<>();
		t.set(1);
		Thread.sleep(1000);
		System.out.println();
	}
}
